package com.zp.common.core.enums;

import com.zp.common.core.utils.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum WeekType {

    MONDAY(1, "星期一"),
    TUESDAY(2, "星期二"),
    WEDNESDAY(3, "星期三"),
    THURSDAY(4, "星期四"),
    FRIDAY(5, "星期五"),
    SATURDAY(6, "星期六"),
    SUN(7, "星期日");

    private final int code;
    private final String label;

    /**
     * 通过 label获取枚举属性
     *
     * @param label
     * @return
     */
    public static WeekType getWednesday (String label) {
        for (WeekType value : values()) {
            if (StringUtils.equals(label, value.getLabel())) {
                return value;
            }
        }
        throw new RuntimeException("'WeekType' not found By " + label);
    }
}
